home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -in_the_mag- / reader_requests / dice_v3.15 / lib / fd / ioctl.c < prev    next >
C/C++ Source or Header  |  1999-01-26  |  1KB  |  67 lines

  1.  
  2. /*
  3.  *  IOCTL.C
  4.  *
  5.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  6.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  7.  *    DICE-LICENSE.TXT.
  8.  */
  9.  
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <fcntl.h>
  13. #include <errno.h>
  14. #include <ioctl.h>
  15.  
  16. long
  17. ioctl(fd, req, arg1)
  18. int fd;
  19. int req;
  20. void *arg1;
  21. {
  22.     _IOFDS *d;
  23.  
  24.     if (d = __getfh(fd)) {
  25.     switch(req) {
  26.     case IOC_MODES|IOF_GET:
  27.         if (arg1)
  28.         *(int *)arg1 = d->fd_Flags & ~O_INTERNAL;
  29.         break;
  30.     case IOC_MODES|IOF_SET:
  31.         d->fd_Flags = (d->fd_Flags & O_INTERNAL) | (*(int *)arg1 & ~O_INTERNAL);
  32.         break;
  33.     case IOC_GETDESC:
  34.         return((long)d->fd_Fh);
  35.     }
  36.  
  37.     if (d->fd_Exec)
  38.         return((*d->fd_Exec)(d->fd_Fh, req, arg1, NULL));
  39.  
  40.     /*
  41.      *  normal file descriptor
  42.      */
  43.  
  44.     switch(req) {
  45.     case IOC_CEXEC|IOF_GET:
  46.         if (arg1)
  47.         *(int *)arg1 = (d->fd_Flags & O_CEXEC) ? 1 : 0;
  48.         return(0);
  49.     case IOC_CEXEC|IOF_SET:
  50.         if (*(int *)arg1)
  51.         d->fd_Flags |= O_CEXEC;
  52.         else
  53.         d->fd_Flags &= ~O_CEXEC;
  54.         return(0);
  55.     case IOC_MODES|IOF_GET:
  56.         return(0);
  57.     case IOC_MODES|IOF_SET:
  58.         return(0);
  59.     case IOC_DOMAIN:
  60.         return(IODOM_AMIGADOS);
  61.     }
  62.     errno = EINVAL;
  63.     }
  64.     return(-1);
  65. }
  66.  
  67.